import { reqGetListInfo } from '@/api/index'
const state = {
  listInfo:{}
}
const mutations = {
  GETLISTINFO(state,listInfo){
    state.listInfo = listInfo
  }
}
const actions = {
  async getListInfo({commit},params ={}){
    let res = await reqGetListInfo(params)
    console.log(res,'res');
    commit('GETLISTINFO',res.data)
  }
}
// 计算属性，为简化数据而生
const getters = {
  // state指的是这里的state,如果这里的网路不好的情况下，listInfo可能为空，里面就没有属性值，得到的结果就是undefind
  goodsList(state){
    return state.listInfo.goodsList || []
  },
  attrsList(state){
    return state.listInfo.attrsList || []
  },
  trademarkList(state){
    return state.listInfo.trademarkList || []
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}